package org.cuijq.thinking.in.spring.dependency.injection;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.event.DefaultEventListenerFactory;

/**
 * @author by CuiJQ
 * @Classname XmlDepencySetterInjectionDemo
 * @Description XmlDepencySetterInjectionDemo Description
 * @Date 2021/6/29 9:04
 */
public class XmlDepencySetterInjectionDemo {

  public static void main(String[] args) {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader beanDefinitionReader =new XmlBeanDefinitionReader(beanFactory);
    String xmlResourcePath = "classpath:/META-INF/dependency-setter-injection.xml";
    //加载 xml 资源，解析并且生成BeanDefintion
    beanDefinitionReader.loadBeanDefinitions(xmlResourcePath);
    //依赖查找并且创建bean

    UserHolder userHolder= beanFactory.getBean(UserHolder.class);
    System.out.println(userHolder);
  }
}
